package com.chenjie.crud.controller;

import com.chenjie.crud.dto.request.query.DeptIdReq;
import com.chenjie.crud.dto.request.query.DeptReqQuery;
import com.chenjie.crud.dto.request.query.StationReq;
import com.chenjie.crud.eo.Dept;
import com.chenjie.crud.service.DeptService;
import com.chenjie.crud.service.StationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

@RestController
@RequestMapping("/v1/dept")
@Api(tags = "DeptController", description = "部门管理")
public class DeptController {


    @Resource
    private DeptService deptService;

    @PostMapping("/createDept")
    @ApiOperation("新增部门管理")
//    @IgnoreResponseWrapper
    public Long createDept(@RequestBody @Valid DeptReqQuery deptReqQuery){
        return deptService.createDept(deptReqQuery);
    }

    @GetMapping("/selectAllDept")
    @ApiOperation("查询所有部门信息")
    public List<Dept> selectAllDept(DeptReqQuery deptReqQuery){
        return deptService.selectAllDept(deptReqQuery);
    }

    @GetMapping("/selectDeptbyId")
    @ApiOperation("通过id查询部门信息")
    public Dept selectDeptbyId(@RequestBody @Valid DeptIdReq deptIdReq){
        return deptService.selectDeptbyId(deptIdReq);
    }

    @PatchMapping("/updateDeptbyId")
    @ApiOperation("通过id修改部门信息")
    public Boolean updateDeptbyId(@RequestBody @Valid DeptReqQuery deptReqQuery){
        return deptService.updateDeptbyId(deptReqQuery);
    }

    @DeleteMapping("/deleteDeptbyId")
    @ApiOperation("通过id删除部门信息")
    public Boolean deleteDeptbyId(@RequestBody @Valid DeptIdReq deptIdReq){
        return deptService.deleteDeptbyId(deptIdReq);
    }


//    public static void main(String[] args) {
////        java.util.Date juDate = new Date();
////        DateTime dt = new DateTime(juDate);
////        System.out.println(dt);
////        DateTime dt = new DateTime();
////        int month = dt.getMonthOfYear();  // where January is 1 and December is 12
////        int year = dt.getYear();
////        System.out.println("dt"+dt);
////        System.out.println("month"+month);
////        System.out.println("year"+year);
//
////        DateTime dt = new DateTime();
////        DateTime year2000 = dt.withYear(2000);
////        DateTime twoHoursLater = dt.plusHours(2);
////                System.out.println("year2000"+year2000);
////        System.out.println("twoHoursLater"+twoHoursLater);
//
//        DateTime dt = new DateTime();
//        String monthName = dt.monthOfYear().getAsText();
//        String frenchShortName = dt.monthOfYear().getAsShortText(Locale.ENGLISH);
//        boolean isLeapYear = dt.year().isLeap();
//        DateTime rounded = dt.dayOfMonth().roundFloorCopy();
//        System.out.println("monthName"+monthName);
//        System.out.println("frenchShortName"+frenchShortName);
//        System.out.println("isLeapYear"+isLeapYear);
//        System.out.println("rounded"+rounded);
//
//    }

}
